package com.example.tic_tac_toe_in_android.view;

import android.content.Context;
import android.content.SharedPreferences;

public class GameSharedPreferences {
	private static final String PREFS = "com.example.tic_tac_toe_in_android.view";
	private static final String KEY = "highscore";

	public GameSharedPreferences() {
		System.out.println("GameSharedPreferences.GameSharedPreferences()");
	}

	public static void save(Context context, String value) {
		// SharedPreferences
		SharedPreferences sp = context.getSharedPreferences(PREFS, 0);
		SharedPreferences.Editor spEditor = sp.edit();

		spEditor.putString(KEY, value);
		spEditor.commit();

	}

	public static String load(Context context) {
		String temp;
		SharedPreferences sp = context.getSharedPreferences(PREFS, 0);
		temp = sp.getString(KEY, "No SCORE");
		return temp;
	}

	public static void remove(Context context) {
		SharedPreferences sp = context.getSharedPreferences(PREFS, 0);
		if (sp.contains(GameSharedPreferences.PREFS + KEY)) {
			SharedPreferences.Editor editor = sp.edit();
			editor.remove(GameSharedPreferences.PREFS + KEY);
			editor.commit();
		}

	}

}
